home *** CD-ROM | disk | FTP | other *** search
/ Informática Multimedia 1995 April / Informatica Multimedia CD - Epimundo.iso / DOS / FMT_COPY / FDREAD.ZIP / FDREAD.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-17  |  19.7 KB  |  297 lines

  1.          page      58,132
  2.              title     fdread - lesen von disketten aller formate
  3.  
  4. cseg         segment   word public 'device_dvr'
  5.              assume    cs:cseg
  6.  
  7.              org       0
  8.              dd        -1                                  ;Nur ein Driver
  9.              dw        1000000000000000b                   ;Character-Device
  10. stra         dw        strategy                            ;Strategy-Routine
  11. entr         dw        entry                               ;Einsprungadresse
  12.              IF        MODE EQ 2
  13.              db        '&FDREAD2'                          ;Dummy-Name
  14.              ELSE
  15.              db        '&FDREAD '                          ;Dummy-Name
  16.              ENDIF
  17.  
  18. error        proc      far
  19.              mov       word ptr es:[bx+3],8103h            ;Fehler, da nur Dummy-Device
  20.              retf                                          ;Ende
  21. error        endp
  22.  
  23. old13        label     dword                               ;Speicherung des alten Interrupt 13
  24. old13_ofs    dw        ?                                   ;Offset-Teil
  25. old13_seg    dw        ?                                   ;Segment-Teil
  26. active       db        1                                   ;bit 0 ON = active.  (CJ)
  27.  
  28. en           proc      far
  29.              cmp       ax,6368h                            ;Special call ("ch")? (CJ)
  30.              jz        spcl                                ;Maybe.               (CJ)
  31. tstact:      test      byte ptr cs:active,01h              ;Are we active?       (CJ)
  32.              jz        exit                                ;Jump if not.         (CJ)
  33.              test      dl,80h                              ;Floppy disk?         (CJ)
  34.              jnz       exit                                ;Jump if not.         (CJ)
  35.              or        ah,ah                               ;Wurde Funktion 0 RESET aufgerufen?
  36.              jz        exit                                ;Ja, dann Ende
  37.              cmp       ah,4                                ;Wurde Funktion über 4 aufgerufen?
  38.              ja        exit                                ;Ja, dann Ende
  39.              push      ax                                  ;Alle benötigten...
  40.              push      ds                                  ;...Register...
  41.              push      bx                                  ;...retten
  42.              xor       bx,bx
  43.              mov       ds,bx                               ;Setze auch DS=0
  44.              lds       bx,ds:[78h]                         ;Disk-Parameter Tabelle in DS:BX
  45.              add       al,cl                               ;Start sector + # sectors   (CJ)
  46.              dec       al                                  ;-1 = highest sector needed.(CJ)
  47.              cmp       al,ds:[bx+4]                        ;Enough sectors in table?   (CJ)
  48.              jna       nochng                              ;Jump if yes.               (CJ)
  49.              mov       ds:[bx+4],al                        ;Setze auf maximal 25 Sektoren/Spur
  50. nochng:      pop       bx                                  ;Alle...
  51.              pop       ds                                  ;...Register...
  52.              pop       ax                                  ;...zurückholen.
  53.              IF        MODE EQ 2
  54.              cmp       dl,3                                ;Laufwerk > 3
  55.              ja        exit                                ;Ja, dann Ende
  56.              or        ch,ch                               ;Track 0 ?
  57.              jz        exit                                ;Ja, dann Ende
  58.              push      ax                                  ;AX für später speichern
  59.              pushf                                         ;Flags pushen da INT-CALL
  60. callpatch:   call      old13                               ;Alten INT 13 aufrufen
  61.              jnc       okexit                              ;Kein Fehler, dann Ende
  62.              pop       ax                                  ;Hole uns AX zurück
  63.              push      ds                                  ;Speichere...
  64.              push      bx                                  ;...DS & BX
  65.              mov       bx,40h                              ;Segment vom BIOS-RAM
  66.              push      bx                                  ;von BX...
  67.              pop       ds                                  ;...nach DS
  68.              mov       bx,90h                              ;Beginn der Drive-Tabelle
  69.              add       bl,dl                               ;Offset des Laufwerks
  70.              cmp       ch,43                               ;Track>43
  71.              ja        nodstep                             ;Ja, dann niemals DSTEP
  72.              xor       byte ptr ds:[bx],20h                ;invertiere das Stepper-Bit
  73.              jmp       short stepend                       ;Ende vom Stepping
  74. nodstep:     and       byte ptr ds:[bx],0dfh               ;Kein Double-Stepping
  75. stepend:     pop       bx                                  ;Hole BX und..
  76.              pop       ds                                  ;...DS zurück
  77.              ENDIF
  78. exit:        jmp       old13                               ;Springe an den alten Interrupt 13
  79.              IF        MODE EQ 2
  80. okexit:      inc       sp                                  ;Werfe den...
  81.              inc       sp                                  ;...gesicherten AX weg
  82.              ret       2                                   ;Und Ende mit original Flags
  83.              ENDIF
  84. ;
  85. ; This routine, and other small changes have been made in this version by Crazy Jack
  86. ; in May, 1990.  The changes are in the public domain.  Some rearranging of the code
  87. ; in other areas was made to reduce the code size.  This routine now responds ONLY to
  88. ; floppy disk I/O requests, and it adjusts the number of sectors in the FD table so
  89. ; that it never exceeds what the user is expecting.  Using a fixed high value causes
  90. ; some programs (PCSHELL, for example) to be unable to format a disk while copying.
  91. ;
  92. ; Also added is a user interface.  Into the AX register place the letters "ch" (the
  93. ; "c" goes in the ah, the "h" goes in the al), and place the characters "cj" into the
  94. ; DX register.  Into the CL register place the new value that you want to store into the
  95. ; flag byte called "active".  Then do an interrupt 13h (the BIOS disk services call).
  96. ; If FDREAD is not installed, this will result in an "invalid command" reply.  If we
  97. ; ARE installed, you will get a clear carry flag, a zero in the AH register, and the
  98. ; PREVIOUS contents of the flag in the AL.  You will also get the segment address of
  99. ; this program in the ES, and the offset to the "active" flag byte in the BX register.
  100. ;
  101. spcl:        cmp       dx,636Ah                            ;Rest of special signature ("cj")?
  102.              jnz       exit                                ;Jump if not.                (CJ)
  103.              push      cs                                  ;Return our segment address. (CJ)
  104.              pop       es                                  ;                            (CJ)
  105. ofsact:      mov       bx,offset active                    ;Return address of flag.     (CJ)
  106.              mov       al,es:[bx]                          ;Return current flag.        (CJ)
  107.              mov       es:[bx],cl                          ;Set new flag value.         (CJ)
  108.              xor       ah,ah                               ;Clear AH and CF.            (CJ)
  109.              sti                                           ;...sure enuf!               (CJ)
  110.              ret       2                                   ;Done.                       (CJ)
  111. en           endp
  112. savreq       label     dword                               ;DWORD zur...
  113. savreq_o     dw        ?                                   ;...Sicherung des...
  114. savreq_s     dw        ?                                   ;...Request Headers
  115.  
  116. strategy     proc      far                                 ;Strategy-Routine
  117.              mov       cs:[savreq_o],bx                    ;BX speichern
  118.              mov       cs:[savreq_s],es                    ;ES speichern
  119.              ret                                           ;...Fertig
  120. strategy     endp
  121.  
  122. entry        proc      far                                 ;Einsprung Routine des Drivers
  123.              assume    cs:cseg
  124.              push      ax                                  ;Alle Register und Flags retten
  125.              push      cx
  126.              push      dx
  127.              push      di
  128.              push      si
  129.              push      ds
  130.              push      es
  131.              push      bx
  132.              pushf
  133.              les       bx,cs:[savreq]                      ;Hole den Request-Header
  134.              mov       al,es:[bx+2]                        ;Lade die Funktion
  135.              cmp       al,0                                ;größer als 0
  136.              jnz       unkwn_com                           ;Ja, Fehler
  137.              jmp       short init                          ;Sonst initialisiere den Treiber
  138. entry        endp
  139.  
  140. rout         proc      far
  141. exit1:       mov       ax,100h                             ;Return ohne Fehler
  142.              jmp       short exgem
  143. unkwn_com:   mov       ax,8103h                            ;Unbekannter Befehl
  144. exgem:       mov       es:[bx+3],ax
  145.              popf                                          ;Alle Register wiederherstellen
  146.              pop       bx
  147.              pop       es
  148.              pop       ds
  149.              pop       si
  150.              pop       di
  151.              pop       dx
  152.              pop       cx
  153.              pop       ax
  154.              ret
  155. rout         endp                                          ;und zurückgehen
  156.  
  157.  
  158. ;Die folgende Routine installiert FDR_OS2 als Device-Driver bei Einbindung
  159. ;in CONFIG.SYS mit dem DEVICE= Befehl
  160. ;HINWEIS: Auch unter DOS 4.xx oder OS/2 bitte mit DEVICE= installieren
  161.  
  162. init:        mov       dx,offset text                      ;Lade Begrüßungstext
  163.              mov       ah,9                                ;AH=9 für...
  164.              int       21h                                 ;...Ausgabe auf Bildschirm
  165.              mov       word ptr es:[bx+14],offset savreq   ;Bis hier resident machen
  166.              mov       es:[bx+16],cs                       ;Segment auch abspeichern
  167.              xor       ax,ax                               ;AX auf Null setzen
  168.              push      ax                                  ;Brauchen wir gleich nochmal
  169.              mov       ds,ax                               ;und DS=0 für Interrupt-Tabelle
  170.              lds       ax,ds:[13h*4]                       ;Lade alten Interrupt 13 in DS:BX
  171.              mov       cs:[old13_ofs],ax                   ;und speichere...
  172.              mov       cs:[old13_seg],ds                   ;...es ab.
  173.              pop       ds                                  ;Nochmal DS=0
  174.              mov       word ptr ds:[13h*4],offset en       ;Setze Offset von neuem INT 13
  175.              mov       ds:[13h*4+2],cs                     ;Setze Segment von neuem INT 13
  176.              mov       word ptr cs:[stra],offset error     ;Alle Device-Driver-Requests...
  177.              mov       word ptr cs:[entr],offset error     ;...mit UNKNOWN COMMAND beantowrten.
  178.              jmp       exit1                               ;und schon fertig.
  179.  
  180.              IF        MODE EQ 2
  181. text         db        'FDREAD2 - Ver 1.20cj - Written by: C.Hochstätter & J.Armengaud',10,10,13,"$"
  182.              ELSE
  183. text         db        'FDREAD - Ver 1.20cj - Written by: C.Hochstätter',10,10,13,"$"
  184.              ENDIF
  185. nimsg        db        10,7,'FDREAD is not installed.',10,13,'$'
  186. fdonmsg      db        'FDREAD is on',10,13,'$'
  187. fdoffmsg     db        'FDREAD is off',10,13,'$'
  188.  
  189. ;Die folgende Routine installiert FDR_OS2 bei Aufruf von der DOS-Kommandozeile.
  190. ;HINWEIS: Diese Installation ist nicht möglich unter OS/2
  191.  
  192. exeinst:     xor       ax,ax                               ;AX=0
  193.              IF        MODE EQ 2
  194.              mov       word ptr cs:[callpatch+3],ax        ;Relativer JUMP ist 0
  195.              ENDIF
  196.              mov       word ptr cs:[exit+3],ax             ;Ok, nicht besonders elegant
  197.                                                            ;(Don't EVER apologize for (CJ)
  198.                                                            ;things like that!!)       (CJ)
  199.              mov       word ptr cs:[ofsact+1],offset active-offset old13 ;See?        (CJ)
  200.              mov       word ptr cs:[tstact+3],offset active-offset old13 ;            (CJ)
  201.              mov       ah,51h                              ;Hole den PSP...
  202.              int       21h                                 ;...in BX
  203.              push      bx                                  ;Speichern...
  204. ;            push      bx          THIS JUST CREATES A     ;2 x
  205. ;            pop       ds          SMALL, GENERALLY USELESS;...in DS
  206. ;            mov       es,ds:[2ch] HOLE IN RAM.  LET'S     ;Environment in ES holen
  207. ;            mov       ah,49h      DROP IT FOR NOW.        ;AH=49, um Environment
  208. ;            int       21h                                 ;freizugeben
  209.              pop       es                                  ;PSP wieder in ES
  210.              push      cs                                  ;DS mit Programm
  211.              pop       ds                                  ;Segment laden
  212. ;
  213. ; We're gonna break in right here and see if there's a command line and see if
  214. ; we need to be installed.
  215. ;
  216.              xor       ch,ch                               ;First we scan the com-    (CJ)
  217.              mov       cl,es:[128]                         ;mand tail.                (CJ)
  218.              mov       di,129                              ;Aim at start.             (CJ)
  219.              mov       al,' '                              ;Scan over any spaces.     (CJ)
  220.              cld                                           ;                          (CJ)
  221.              repe      scasb                               ;                          (CJ)
  222.              dec       di                                  ;Back up to character found(CJ)
  223.              mov       ax,es:[di]                          ;Pick up two of them.      (CJ)
  224.              or        ax,2020h                            ;Force lower case.         (CJ)
  225.              cmp       al,'o'                              ;Is the first one "o"?     (CJ)
  226.              jne       noO                                 ;Jump if not,              (CJ)
  227.              mov       al,ah                               ;else get 2nd char.        (CJ)
  228. noO:         push      es                                  ;Save results and stuff.   (CJ)
  229.              push      ax                                  ;                          (CJ)
  230.              mov       ax,6368h                            ;Now see if we're          (CJ)
  231.              mov       dx,636Ah                            ;already installed         (CJ)
  232.              mov       cl,1                                ;(try to change status).   (CJ)
  233.              int       13h                                 ;                          (CJ)
  234.              jnc       alrdyin                             ;Jump if already installed.(CJ)
  235.              pop       ax                                  ;Get restored.             (CJ)
  236.              pop       es                                  ;                          (CJ)
  237.              cmp       al,' '                              ;Install?                  (CJ)
  238.              je        inwego                              ;Jump if yes....           (CJ)
  239.              mov       dx,offset nimsg                     ;Send error message.       (CJ)
  240.              mov       ah,9                                ;                          (CJ)
  241.              int       21h                                 ;                          (CJ)
  242.              mov       ax,4C69h                            ;Exit with not-zero        (CJ)
  243.              int       21h                                 ;error level code.         (CJ)
  244.  
  245. alrdyin:     mov       cl,al                               ;Keep original setting.    (CJ)
  246.              pop       ax                                  ;Get back command.         (CJ)
  247.              cmp       al,'n'                              ;Is command "on"?          (CJ)
  248.              jne       tryf                                ;Jump if not,              (CJ)
  249.              mov       cl,1                                ;else set if to ON.        (CJ)
  250.              jmp       short fdset                         ;                          (CJ)
  251. tryf:        cmp       al,'f'                              ;Okay, is it "off"?        (CJ)
  252.              jne       showhat                             ;Jump if just display.     (CJ)
  253.              xor       cl,cl                               ;Set it to OFF.            (CJ)
  254.              jmp       short fdset                         ;Go set new value.         (CJ)
  255.  
  256. showhat:     push      cx                                  ;Save switch value.        (CJ)
  257.              mov       dx,offset fdonmsg                   ;Select 'off' or           (CJ)
  258.              or        cl,cl                               ;"on" message as the       (CJ)
  259.              jnz       pumpitout                           ;situation requires.       (CJ)
  260.              mov       dx,offset fdoffmsg                  ;                          (CJ)
  261. pumpitout:   mov       ah,9                                ;                          (CJ)
  262.              int       21h                                 ;Display the result.       (CJ)
  263.              pop       cx                                  ;Get back switch value.    (CJ)
  264. fdset:       mov       ax,6368h                            ;Send it off to            (CJ)
  265.              mov       dx,636Ah                            ;already installed         (CJ)
  266.              int       13h                                 ;copy of FDREAD.           (CJ)
  267.              mov       al,cl                               ;Return code = flag.       (CJ)
  268.              mov       ah,4Ch                              ;Then do a benign          (CJ)
  269.              int       21h                                 ;end of job.               (CJ)
  270. ;
  271. ; --and now back to the installation code:
  272. ;
  273. inwego:      mov       dx,offset text                      ;Begrüßungstext laden
  274.              mov       ah,9                                ;Und über INT 21...
  275.              int       21h                                 ;...auf Bildschirm ausgeben
  276.              mov       di,60h                              ;Hier können wir die Routine laden
  277.              mov       si,offset old13                     ;Und zwar ab hier
  278.              mov       cx,(offset savreq-offset old13+1)/2 ;mit dieser Länge
  279.              cld
  280.              rep       movsw                               ;Ok, verschiebe den Code
  281.              mov       ax,es                               ;Nun DS auf neues...
  282.              add       ax,6                                ;...Segment...
  283.              mov       ds,ax                               ;...setzen.
  284.              mov       ax,3513h                            ;Lade die alte INT 13 Routine
  285.              int       21h                                 ;über DOS Call
  286.              mov       ds:[0],bx                           ;Speichere die Werte ab
  287.              mov       ds:[2],es                           ;Segment und Offset
  288.              mov       dx,offset en-offset old13           ;Beginn der Service-Routine
  289.              mov       ax,2513h                            ;Über DOS-Call
  290.              int       21h                                 ;installieren
  291.              mov       ax,3103h                            ;Wir bleiben speicherresident
  292.              mov       dx,(offset savreq-offset old13+15)/16+6;Anzahl der benötigten
  293.              int       21h                                 ;Paragraphen Und Ende
  294.  
  295. cseg         ends
  296.              end       exeinst
  297.